//     Copyright (c) Microsoft Corporation.  All rights reserved.

using System;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Linq;
using Gateway.Console.Models;

namespace Gateway.Console.Migrations
{
    internal sealed class Configuration : DbMigrationsConfiguration<ConsoleContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = true;
            AutomaticMigrationDataLossAllowed = true;
            ContextKey = "Gateway.Console.Models.ConsoleContext";
        }

        protected override void Seed(ConsoleContext context)
        {
            context.AnalyticsReportModels.AddOrUpdate(
                report => report.Report,
                new AnalyticsReportModel
                {
                    Report = "VisitorsByWeek",
                    Description = "Unique Visitors By Week",
                    HasMultipleSeries = false,
                    TickInterval = "week",
                    TickFormat = "%d-%b-%Y",
                    HiveTable = "VisitorsByWeek",
                    DistinctExpression = "csusername",
                },
                new AnalyticsReportModel
                {
                    Report = "ErrorsByWeek",
                    Description = "Application Errors (4xx, 5xx Status Code)",
                    HasMultipleSeries = true,
                    SeriesColumn = "scstatus",
                    TickInterval = "week",
                    TickFormat = "%d-%b-%Y",
                    HiveTable = "ErrorsByWeek",
                    FilterPredicate = "scstatus >= 400",
                },
                new AnalyticsReportModel
                {
                    Report = "UsageByTenantByMonth",
                    Description = "Usage By Tenant",
                    HasMultipleSeries = true,
                    SeriesColumn = "tenant",
                    TickInterval = "month",
                    TickFormat = "%b-%Y",
                    HiveTable = "TenantRequestsByMonth",
                });
        }
    }
}
